package view;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import view.action.Action;
import view.action.ActionFactory;


/**
 * Servlet implementation class SystemStudent
 */
public class FrontController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		try {
			request.setCharacterEncoding("UTF-8");
			Action action = ActionFactory.getAction(request);
			String view = request.getContextPath()+ action.execute(request, response);
			response.sendRedirect(view);
		} catch (Exception e) {
			throw new ServletException("Executing action failed.", e);
		}
	}
}
